package com.whz.singleton;

import java.io.*;

/**
 * @Author: sinosoft
 * @Description:
 * @Date: Create in 19:40 2021/4/29
 * @Modified By:
 */
public class SerializableDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Elvis.txt"));
        oos.writeObject(Elvis2.INSTANCE);
        Elvis2 e1 = Elvis2.INSTANCE;

        File file = new File("Elvis.txt");
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
        Elvis2 e2 = (Elvis2) ois.readObject();
        System.out.println("e1: " + e1);
        System.out.println("e2: " + e2);


    }
}
